
<%@ page language="java" import="java.util.*" pageEncoding="utf-8"%>
<%@ taglib uri="http://java.sun.com/jstl/core_rt" prefix="c"%>
<%@ taglib uri="/resource/UserPwoer.tld" prefix="p"%>
<c:set var="path" value="${pageContext.request.contextPath }" />
<!DOCTYPE HTML>
<html>
<head>
<meta charset="utf-8">
<META HTTP-EQUIV="Pragma" CONTENT="no-cache">
<meta name="renderer" content="webkit|ie-comp|ie-stand">
<meta http-equiv="X-UA-Compatible" content="IE=edge,chrome=1">
<meta name="viewport"
	content="width=device-width,initial-scale=1,minimum-scale=1.0,maximum-scale=1.0,user-scalable=no" />
<meta http-equiv="Cache-Control" content="no-siteapp" />
<LINK rel="Bookmark" href="../images/favicon.ico">
<!-- 本框架基本脚本和样式 -->
<script type="text/javascript"
	src="${path }/resource/js/jquery-2.1.4.min.js"></script>
<script type="text/javascript"
	src="${path }/resource/js/systools/MBase.js"></script>
</head>
<body class="gray-bg">
	<nav class="huiNav">
		<%@include file="project-nav.jsp"%>${param.projName }
		<a class="btn btn-info  btn-sm pull-right"
			href="javascript:location.replace(location.href);" title="刷新"><i
			class="fa fa-refresh"></i></a>
	</nav>

	<div class="ibox-content">
		<%-- <jsp:include page="proj-manager-son.jsp"></jsp:include> --%>
		<!-- 搜索框部分start -->
		<div class="row">
			<div class="col-sm-9">
				<form class="form-inline" id="serchform">
					<%-- <input type="hidden" name="projId" id="projId" value="${param.projId}"> --%>
					<div class="form-group mr-20">
						<label for="exampleInputName2">通用区域</label> <select
							class="form-control autoFull" name="commonCaseArea" dataType="*"
							data-url="${path}/admin/dataDictionary/showDataDictionary"
							data-filed="name" data-value="name" data-param="{type:'通用区域'}">
							<option value="">--请选择通用区域--</option>
						</select>
					</div>

					<div class="form-group mr-20">
						<label for="exampleInputName2">标题</label> <input name="title"
							type="text" class="form-control" value="">
					</div>

					<div class="form-group mr-20">
						<label for="exampleInputName2">编号</label> <input name="caseId"
							type="text" class="form-control" value="">
					</div>
					
					<br/>

					<div class="form-group mr-20">
						<label for="exampleInputName2">类型</label> <select
							class="form-control autoFull" name="caseType" dataType="*"
							data-url="${path}/admin/dataDictionary/showDataDictionary"
							data-filed="name" data-value="name" data-param="{type:'用例类型'}">
							<option value="">--请选择用例类型--</option>
						</select>
					</div>

					<div class="form-group mr-20">
						<label for="exampleInputName2">优先级</label> <select
							class="form-control autoFull" name="grade">
							<option value="">--请选择优先级--</option>
							<option value="1">1</option>
							<option value="2">2</option>
							<option value="3">3</option>
							<option value="4">4</option>
						</select>
					</div>
					
					<button onclick="myGrid.serchData()" type="button"
						class="btn btn-info btn-sm">
						<i class="fa fa-search "></i> 搜索
					</button>
					<button type="reset" class="btn btn-info btn-sm">
						<i class="fa fa-refresh "></i> 重置
					</button>
				</form>
			</div>
		</div>
		<!-- 搜索框部分en -->
		<div style="position: relative; top: 40px; z-index: 12; width: 200px;">
			<button onclick="myGrid.delItems('caseId')" type="button"
				class="btn btn-danger btn-sm">
				<i class="fa fa-trash"></i>批量删除
			</button>
			<button onclick="openAdd()" type="button"
				class="btn btn-success btn-sm">
				<i class="fa fa-plus"></i> 新增
			</button>
		</div>
		<div class="row">
			<div class="col-md-12">
				<table id="mgrid">
					<thead>
						<tr>
							<th data-checkbox="true"></th>
							<th data-field="caseId">用例编号</th>
							<th data-field="title" data-formatter="buidTitle">标题</th>
							<th data-field="commonCaseArea">通用区域</th>
							<th data-field="caseType">用例类型</th>
							<th data-field="userStage">适用阶段</th>
							<th data-field="userName">创建人</th>
							<th data-field="createTime" data-formatter="MGrid.getTime">创建时间</th>
							<!-- <th data-field="success" data-formatter="buidSuccess">成功：失败</th>
							<th data-field="caseStatus" data-formatter="buidStatus">状态</th> -->
							<th data-align="center" data-width="195px" 
								data-formatter="buidOperate">操作</th>
						</tr>
					</thead>
				</table>
			</div>
		</div>
	</div>
	<script type="text/javascript">
		var myGrid;
		$(function() {
			var delUrl = "";
			delUrl = "${path}/admin/commonUserCase/del";
			myGrid = MGrid.initGrid({
				url : "${path}/admin/commonUserCase/showList",
				delUrl : delUrl,
			});

		});
		function buidTitle(value, row, index) {
			return '<span  class="badge badge-info" >' + row.grade + '</span> '
					+ value;
		}
		function buidSuccess(value, row, index) {
			return "<b>" + row.success + ' : ' + row.fail + "</b>";
		}
		function buidStatus(value, row, index) {
			var color = "";
			if (value == "通过") {
				color = "success"
			} else if (value == "失败") {
				color = "danger"
			} else if (value == "N/A") {
				color = "default"
			} else if (value == "正常") {
				color = "info"
			} else if (value == "阻塞") {
				color = "warning"
			}
			return "<span class='label label-"+color+"'>" + value + "</span>";
		}
		function buidOperate(value, row, index) {
			var html = '';
			html += '<button class="btn btn-default btn-sm mr-5" onClick="openEdit('
					+ row.caseId
					+ ')" title="编辑"><i class="fa fa-edit"></i></buttoun>';
			html += '<button class="btn btn-default btn-sm mr-5" onClick="myGrid.delItem('
					+ row.caseId
					+ ')" title="删除"><i class="fa fa-lg fa-trash-o"></i></buttoun>';
			return html;
		}
		//打开添加界面
		function openAdd() {
			layer
					.full(layer
							.open({
								type : 2,
								title : "新增用例",
								area : [ MUI.SIZE_L, '400px' ],
								content : [ '${path}/admin/commonUserCase/editForm' ]
							}));
		}
		//打开编辑界面
		function openEdit(id) {
			layer.full(layer.open({
				type : 2,
				title : "编辑用例",
				area : [ MUI.SIZE_L, '400px' ],
				content : [ '${path}/admin/commonUserCase/editForm?id=' + id]
			}));
		}
		$(".select2").select2({
			'width' : '100%'
		});
		MTools.autoFullSelect();
		
	</script>
</body>
</html>
